Skip to content

London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 3 | implement and rewrite tests coursework#1261

Open
djebsoft wants to merge 11 commits intoCodeYourFuture:mainfrom
djebsoft:sprint-3/implement-and-rewrite-tests-coursework
Open

London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 3 | implement and rewrite tests coursework#1261
djebsoft wants to merge 11 commits intoCodeYourFuture:mainfrom
djebsoft:sprint-3/implement-and-rewrite-tests-coursework

Conversation

@djebsoft
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

implement and tests functions

Questions

@djebsoft djebsoft added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 13, 2026
Comment on lines +32 to +36
if (card[0] === "A") return 11;
if (["J", "Q", "K"].includes(card[0])) return 10;
if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(card[0]))
return card[0]; // the parseint() or Number() can be used to convert the string to a number
throw new Error("invalid rank");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does your function return the value you expected from each of the following function calls?

getCardValue("+2♠");
getCardValue("2.0♠");
getCardValue("11♠");
getCardValue("2      ♠");
getCardValue("XYZ2♠");

Comment on lines +42 to +45
expect(getAngleType(-1)).toEqual("Invalid angle");
expect(getAngleType(0)).toEqual("Invalid angle");
expect(getAngleType(360)).toEqual("Invalid angle");
expect(getAngleType(361)).toEqual("Invalid angle");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job in identifying both boundary cases.

Comment on lines +22 to +32
// case: the absolute value of the numerater is less than the absolute value of the denominater (proper fraction)
test(`should return true for positive proper fraction`, () => {
expect(isProperFraction(1, 2)).toEqual(true);
});

// case: the absolute value of the denominater is less than the absolute value of the numerater (improper fraction)
test(`should return false for positive improper fraction`, () => {
expect(isProperFraction(2, 1)).toEqual(false);
});

// no need to test the cases where the denominator or numerator or both are negative as I used their absolute value in the function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • In software industry, the test script we prepared may be used to test future implementation/modification. As a practice, can you also test negative numerator/denominator to make the tests comprehensive?

  • For proper fractions, the condition is, "the absolute value of denominator is larger than the absolute value of the numerator". So we can create a category for proper fractions and describe it as:
    should return true when abs(numerator) < abs(denominator)
    and then test all combinations of positive/negative numerator and denominator (for proper fraction) in this category.

Comment on lines 8 to +19
test(`Should return 11 when given an ace card`, () => {
expect(getCardValue("A♠")).toEqual(11);
});
test(`Should return 11 when given an ace card`, () => {
expect(getCardValue("A♥")).toEqual(11);
});
test(`Should return 11 when given an ace card`, () => {
expect(getCardValue("A♦")).toEqual(11);
});
test(`Should return 11 when given an ace card`, () => {
expect(getCardValue("A♣")).toEqual(11);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea to test all suit. I think you can combine these tests into a single category.

Comment on lines +23 to +49
test(`Should return 2 when given a 2 card`, () => {
expect(getCardValue("2♠")).toEqual(2);
});
test(`Should return 3 when given a 3 card`, () => {
expect(getCardValue("3♥")).toEqual(3);
});
test(`Should return 4 when given a 4 card`, () => {
expect(getCardValue("4♦")).toEqual(4);
});
test(`Should return 5 when given a 5 card`, () => {
expect(getCardValue("5♣")).toEqual(5);
});
test(`Should return 6 when given a 6 card`, () => {
expect(getCardValue("6♥")).toEqual(6);
});
test(`Should return 7 when given a 7 card`, () => {
expect(getCardValue("7♠")).toEqual(7);
});
test(`Should return 8 when given a 8 card`, () => {
expect(getCardValue("8♦")).toEqual(8);
});
test(`Should return 9 when given a 9 card`, () => {
expect(getCardValue("9♠")).toEqual(9);
});
test(`Should return 10 when given a 10 card`, () => {
expect(getCardValue("10♣")).toEqual(10);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to test all number cards.

You could also consider combining them into a single category (since they are all number cards), as:

test("should return the value of number cards (2-10)", () => {
    expect(getCardValue("2♣︎")).toEqual(2);
    ...
    expect(getCardValue("10♥")).toEqual(10);

    // or use a loop to check all values from 2 to 10.
});

And perhaps one category for J, Q, K (face cards) and one category for invalid cases.

Comment on lines 13 to 19
function isProperFraction(numerator, denominator) {
// TODO: Implement this function
if (Math.abs(numerator) < Math.abs(denominator)) {
return true;
} else {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be a syntax error in this function.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants